#!/bin/sh

while true
do
	site1=`ping -c 1 baidu.com | grep "ttl=" | wc -l`
	
	if [ $site1 -eq 0 ]; then
		site2=`ping -c 1 www.zjzd-tech.com | grep "ttl=" | wc -l`
		if [ $site2 -eq 0 ]; then	
			echo "network fail"
			sudo route del default gw 192.168.1.1
			sudo sh /home/wwwroot/pavgps/ppp-kill
			sleep 2
			sudo echo -e "AT+CFUN=0\r\n" >/dev/ttyUSB2
			sleep 2
			sudo echo -e "AT+CFUN=1\r\n" >/dev/ttyUSB2
			sleep 10
			sudo sh /home/wwwroot/pavgps/pppd.sh 
			sleep 8
		fi
	else
		echo "network success"
	fi
	sleep 30
done

